package com.maxima.attendance.pojos;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.maxima.attendance.utils.DateOperations;

@Entity
@Table(name = "\"timeLog\"")
@NamedQuery(name = "TimeLog.findAll", query = "SELECT t FROM TimeLog t")
public class TimeLog implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(unique = true, nullable = false)
	private Integer id;
	@Column(length = 150)
	private String comment;
	@Column(columnDefinition = "date")
	private Date recordDate;
	@Column
	private Date loginTime;
	@Column
	private Date logoutTime;
	@Column
	private Boolean workFromHome;
	@Column
	private Integer userId;

	public Boolean getWorkFromHome() {
		return workFromHome;
	}

	public void setWorkFromHome(Boolean workFromHome) {
		this.workFromHome = workFromHome;
	}

	public TimeLog(Date date, Integer userId) {
		this.recordDate = DateOperations.setZeroTime(date);
		this.workFromHome = false;
		this.userId = userId;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public TimeLog(Date date, Integer userId, String comment) {
		super();
		this.recordDate = DateOperations.setZeroTime(date);
		this.userId = userId;
		this.workFromHome = false;
		this.comment = comment;
	}

	public TimeLog() {
		this.workFromHome = false;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = DateOperations.setZeroTime(recordDate);
	}

	public Date getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public Date getLogoutTime() {
		return logoutTime;
	}

	public void setLogoutTime(Date logoutTime) {
		this.logoutTime = logoutTime;
	}
}